[wip] js2py to quickjs#38473
Conversation
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the js2py library with quickjs-ng for executing JavaScript UDFs in Beam YAML, addressing compatibility issues with Python 3.12. The implementation introduces a _JsWrapper class that utilizes thread-local caching for JavaScript functions and handles data transfer via JSON. Feedback includes suggestions to move the thread-local cache to the module level for better idiomaticity, removing a redundant local import of quickjs, and improving the regex used to identify JavaScript function names to support async declarations.
ebf6880 to
9b29dc3
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the js2py library with quickjs-ng for executing JavaScript UDFs within Beam YAML. Key changes include the introduction of a _JsWrapper class and a thread-local cache for JavaScript functions. Feedback focuses on potential regressions and performance issues caused by using JSON serialization for data transfer, fragility in the JavaScript variable unpacking logic for non-standard field names, and a restrictive regex for identifying function names in callables.
74269ed to
f4217b0
Compare
fix SomeTransform picklability in readme_test.py fix lint address gemini comments
f4217b0 to
102cc4f
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request replaces the js2py library with quickjs-ng for executing JavaScript UDFs in Beam YAML. Key changes include the introduction of a thread-local cache for compiled JS functions and expanded support for bytes, datetime, and Decimal types during Python-to-JS conversion. Feedback was provided regarding potential data corruption when decoding bytes with replacement characters and precision loss when casting Decimal to float. Additionally, the regex-based approach for extracting function names from JS callables is noted as being too restrictive for arrow functions, with a more robust wrapping approach suggested.
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request migrates the JavaScript execution engine in Apache Beam's YAML module from js2py to quickjs-ng. This change addresses compatibility issues with newer Python versions and enhances the robustness of JavaScript UDFs by adding better type coercion and improved function caching mechanisms. Highlights
New Features🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request replaces the js2py library with quickjs-ng for executing JavaScript UDFs in Beam YAML, enabling support for Python 3.12. The changes include a new _JsFunctionWrapper class using thread-local storage for caching JS functions, updated type conversion logic in py_value_to_js_dict, and the removal of the js2py-specific object wrapping logic. Feedback highlights several potential issues: converting date/time objects to ISO strings is a breaking change for UDFs expecting JS Date objects; decoding bytes as strict UTF-8 may crash pipelines with binary data; the lack of error handling around JS execution reduces debuggability; and the variable unpacking logic for JS expressions is susceptible to syntax errors from JS reserved words and incorrect substring matching.
There was a problem hiding this comment.
Code Review
This pull request replaces the js2py library with quickjs-ng for JavaScript UDF support in Beam YAML, ensuring compatibility with Python 3.12+. The implementation introduces a thread-local cache for JavaScript functions and expands the py_value_to_js_dict utility to handle bytes, datetime, and Decimal types. Review feedback highlighted a critical API error where quickjs.Context should be used instead of the non-existent quickjs.Function in the quickjs-ng package. Additionally, improvements were suggested to avoid data corruption when handling binary data and to prevent syntax errors when concatenating user-provided JavaScript code with internal wrappers.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>instead.CHANGES.mdwith noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.